
<script src="jquery-3.5.1.min.js"></script>

<script language="javascript">
function send(){
jQuery.ajax({
            type: "POST",
            url: 'service.php',
            data: {functionname: 'snd', arguments: [document.getElementById("msg").innerText]},
            success:function(data) {
                alert(data.toString());
            }
});
}
</script>
<textarea id="msgs" cols="30" rows="8" placeholder="无消息"></textarea>

<textarea id="msg" cols="30" rows="1" placeholder="请输入消息"></textarea>
<button onclick="send()">发送</button>
<?php

    $json_string = file_get_contents('usr.json');

    $d = json_decode($json_string,true);
    ob_start(); 
    $userName=$_COOKIE['usn'];
    $password=$_COOKIE['pwd'];
ob_end_flush();
    if($d[$userName]['pass']===$password&&$userName!=null){
        echo "<script>document.getElementById('msgs').value='".$d['msg']."';</script>";
       
    }else{

        echo "<script type='text/javascript'>";
        echo "window.location.href='login.html'";
        echo "</script>";

    }
